package com.ywu.sentinel.standard.api;

import com.ywu.common.result.CommonResult;
import com.ywu.sentinel.sdk.dto.YwuBlowRuleDto;
import com.ywu.sentinel.sdk.dto.YwuFlowRuleDto;
import com.ywu.sentinel.sdk.dto.YwuHotRuleDto;
import com.ywu.sentinel.sdk.dto.YwuSystemRuleDto;
import com.ywu.sentinel.standard.service.YwuFlowRuleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName YwuFlowRuleApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2025/4/14 18:49
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/sentinel/rule")
public class YwuFlowRuleApi {

    @Autowired
    private YwuFlowRuleService service;

    /**
    * @Author GroundDemo
    * @Description 添加流控规则
    * @Date 18:51 2025/4/14
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flow.rule.create.info")
    public CommonResult<Object> createFlowRule(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.createFlowRule(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 删除流控规则
    * @Date 19:07 2025/4/14
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flow.rule.delete.info")
    public CommonResult<Object> deleteFlowRule(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.deleteFlowRule(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改规则信息
    * @Date 13:36 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flow.rule.update.info")
    public CommonResult<Object> updateFlowRule(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.updateFlowRule(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询流控规则列表
    * @Date 19:10 2025/4/14
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flow.rule.list.info")
    public CommonResult<Object> queryFlowRuleList(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.queryFlowRuleList(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 分页查询流控列表
    * @Date 12:18 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/flow.rule.page.list.info")
    public CommonResult<Object> queryFlowRulePageList(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.queryFlowRulePageList(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 添加熔断规则
     * @Date 18:51 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/blow.rule.create.info")
    public CommonResult<Object> createBlowRule(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.createBlowRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除熔断规则
     * @Date 19:07 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/blow.rule.delete.info")
    public CommonResult<Object> deleteBlowRule(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.deleteBlowRule(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改熔断规则
    * @Date 13:48 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/blow.rule.update.info")
    public CommonResult<Object> updateBlowRule(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.updateBlowRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 查询熔断规则列表
     * @Date 19:10 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/blow.rule.list.info")
    public CommonResult<Object> queryBlowRuleList(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.queryBlowRuleList(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 分页查询
    * @Date 14:30 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/blow.rule.page.list.info")
    public CommonResult<Object> queryBlowRulePageList(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.queryBlowRulePageList(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 添加热点规则
     * @Date 18:51 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/hot.rule.create.info")
    public CommonResult<Object> createHotRule(@RequestBody YwuHotRuleDto ruleDto) {
        return service.createHotRule(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改热点规则
    * @Date 13:52 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/hot.rule.update.info")
    public CommonResult<Object> updateHotRule(@RequestBody YwuHotRuleDto ruleDto) {
        return service.updateHotRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除热点规则
     * @Date 19:07 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/hot.rule.delete.info")
    public CommonResult<Object> deleteHotRule(@RequestBody YwuHotRuleDto ruleDto) {
        return service.deleteHotRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 查询热点规则列表
     * @Date 19:10 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/hot.rule.list.info")
    public CommonResult<Object> queryHotRuleList(@RequestBody YwuHotRuleDto ruleDto) {
        return service.queryHotRuleList(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 分页查询
    * @Date 14:35 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/hot.rule.page.list.info")
    public CommonResult<Object> queryHotRulePageList(@RequestBody YwuHotRuleDto ruleDto) {
        return service.queryHotRulePageList(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 创建系统规则
    * @Date 18:55 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/system.rule.create.info")
    public CommonResult<Object> createSystemRule(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.createSystemRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 修改系统规则
     * @Date 13:52 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/system.rule.update.info")
    public CommonResult<Object> updateSystemRule(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.updateSystemRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除系统规则
     * @Date 19:07 2025/4/14
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/system.rule.delete.info")
    public CommonResult<Object> deleteSystemRule(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.deleteSystemRule(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 分页查询
     * @Date 14:35 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/system.rule.page.list.info")
    public CommonResult<Object> querySystemRulePageList(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.querySystemRulePageList(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 查询当前微服务内部的所有热点规则
     * @Date 0:33 2025/4/15
     * @Param []
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @GetMapping("/all.rule.inner.list.info")
    public CommonResult<Object> queryAllRuleInnerList(@Param("serviceName") String serviceName) {
        return service.queryAllRuleInnerList(serviceName);
    }
}
